package com.example.librarymanagementproject2.model.document;

import com.example.librarymanagementproject2.model.enums.UserRole;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.time.LocalDateTime;

/**
 * @ClassName UserDocument
 * @Description 用户文档信息
 * @Author Kx
 * @Date 2025/10/22 20:18
 * @Version 1.0
 */
@Document(indexName = "user", createIndex = false)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserDocument {
    @Id
    private Long id; // 编号
    @Field(type = FieldType.Keyword, index = false)
    private String username; // 用户名
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String realName; // 真实姓名
    @Field(type = FieldType.Keyword, index = false)
    private UserRole role; // 角色
    @Field(type = FieldType.Integer, index = false)
    private Integer status; // 状态(0-禁用，1-正常，2-注销s)
    @Field(type = FieldType.Keyword, index = false)
    private String email; // 邮箱
    @Field(type = FieldType.Keyword, index = false)
    private String image; // 头像
    @Field(type = FieldType.Keyword, index = false)
    private String imageUrl; // 头像临时访问路径
    @Field(type = FieldType.Integer, index = false)
    private Integer maxBorrowNum; // 最多可借阅
    @Field(type = FieldType.Date, index = false)
    private LocalDateTime createTime; // 创建时间
    @Field(type = FieldType.Date, index = false)
    private LocalDateTime updateTime; // 更新时间
    @Field(type = FieldType.Date, index = false)
    private LocalDateTime cancelTime; // 注销时间
}